import {createStore} from 'redux'

import {AnimalInterface} from '../types/home.d'

interface Istate{
    list:AnimalInterface[]
}

let reducer = (state:Istate={list:[]},action:any) => {
    switch (action.type) {
        case 'INIE_LIST':
            //action.list
            return {list:[...action.list]};
        case 'ADD_ANMIAL':{
            //action newAnimal
            console.log(action.newAnimal)
            return {list:[action.newAnimal,...state.list]}
        }
        default:
            return state;
    }
}

let store = createStore(reducer)

export default store